<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<!--<li>
								点位ID：<input type="text" name="pointId"/>
							</li>-->

							<li>
								设备名称：<input type="text" name="name"/>
							</li>

							<!--<li>
								运行编号：<input type="text" name="runCode"/>
							</li>-->

							<!--<li>
								专公变：<input type="text" name="zgb"/>
							</li>-->

							<!--<li>
								规格型号：<input type="text" name="model"/>
							</li>-->

							<!--<li>
                                电压等级：<select id="voltage" name="voltage"
                                            th:with="type=${@dict.getType('voltage_grade')}">
                                        <option th:text="全部" value=""></option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
							</li>-->

							<!--<li>
								变压器容量：<input type="text" name="volume"/>
							</li>

							<li>
								运维班组：<input type="text" name="runTeam"/>
							</li>

							<li>
								所属站房：<input type="text" name="station"/>
							</li>-->

							<!--<li>
								运行状态：<input type="text" name="runStatus"/>
							</li>-->

							<li>
								投运日期：<input type="date" name="runDate"/>
							</li>

							<!--<li>
								生产厂家：<input type="text" name="factory"/>
							</li>

							<li>
								安装形式：<input type="text" name="installType"/>
							</li>

							<li>
								结线别组：<input type="text" name="lineTeam"/>
							</li>

							<li>
								相数：<input type="text" name="xNumber"/>
							</li>

							<li>
								资产单位：<input type="text" name="unit"/>
							</li>

							<li>
								所属10kv线路ID：<input type="text" name="line10kvId"/>
							</li>

							<li>
								所属10kv线路名称：<input type="text" name="line10kvName"/>
							</li>

							<li>
								资产性质：<input type="text" name="natureQuality"/>
							</li>

							<li>
								gis编码：<input type="text" name="gisCode"/>
							</li>

							<li>
								经度：<input type="text" name="lgt"/>
							</li>

							<li>
								纬度：<input type="text" name="lat"/>
							</li>

							<li>
								高程：<input type="text" name="alt"/>
							</li>

							<li>
								创建人：<input type="text" name="addUser"/>
							</li>

							<li>
								创建日期：<input type="date" name="addDate"/>
							</li>

							<li>
								最近更新人：<input type="text" name="updateUser"/>
							</li>

							<li>
								最近更新日期：<input type="date" name="updateDate"/>
							</li>

							<li>
								数据状态：<input type="text" name="datastate"/>
							</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="assets:bByq:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.editFull()" shiro:hasPermission="assets:bByq:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="assets:bByq:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="exportByq()">
						<i class="fa fa-download"></i> 导出变压器统计
				 </a>
				<!--<a class="btn btn-warning" onclick="exportAllAssets()">
						<i class="fa fa-download"></i> 导出全所资产表
				 </a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('assets:bByq:edit')}]];
        var removeFlag = [[${@permission.hasPermi('assets:bByq:remove')}]];
        var voltageGradeDatas = [[${@dict.getType('voltage_grade')}]];
        var prefix = ctx + "assets/bByq";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                showExport:false,		// 是否支持导出文件
                showSearch:false,		//是否显示检索信息
                showRefresh:false,		//是否显示刷新按钮
                showToggle:false,		//是否显示详细视图和列表视图的切换按钮
                showColumns:false,		//是否显示隐藏某列下拉框
                sortable:false,		 	//是否启用排序
                modalName: "变压器",
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'id',
					visible: false
				},
				{
					field : 'pointId', 
					title : '点位ID',
					sortable: true,
                    visible: false
				},
				{
					field : 'name', 
					title : '设备名称',
					sortable: true
				},
				{
					field : 'runCode', 
					title : '运行编号',
					sortable: true,
					visible:false
				},
				{
					field : 'zgb', 
					title : '专公变',
					sortable: true,
                    visible: false
				},
				{
					field : 'model', 
					title : '规格型号',
					sortable: true,
                    visible: false
				},
				{
					field : 'voltage', 
					title : '电压等级',
					sortable: true,
                    formatter: function (value, row, index) {
					    return value;
//                        return $.table.selectDictLabel(voltageGradeDatas, value);
                    }
				},
				{
					field : 'volume', 
					title : '变压器容量',
					sortable: true
				},{
					field : 'nowVolume',
					title : '现场核对容量',
					sortable: true
				},
				{
					field : 'runTeam', 
					title : '运维班组',
					sortable: true,
                    visible: false
				},
				{
					field : 'station', 
					title : '所属站房',
					sortable: true,
                    visible: false
				},
				{
					field : 'runStatus', 
					title : '运行状态',
					sortable: true,
                    visible: false
				},
				{
					field : 'runDate', 
					title : '投运日期',
					sortable: true,
                    formatter: function (value, row, index) {
                        return value!=null?new Date(value).Format('yyyy-MM-dd'):"";
                    }
				},
				{
					field : 'factory', 
					title : '生产厂家',
					sortable: true,
                    visible: false
				},
				{
					field : 'installType', 
					title : '安装形式',
					sortable: true,
                    visible: false
				},
				{
					field : 'lineTeam', 
					title : '结线别组',
					sortable: true,
                    visible: false
				},
				{
					field : 'xNumber', 
					title : '相数',
					sortable: true,
                    visible: false
				},
				{
					field : 'unit', 
					title : '资产单位',
					sortable: true,
                    visible: false
				},
				{
					field : 'line10kvId', 
					title : '所属10kv线路ID',
					sortable: true,
                    visible: false
				},
				{
					field : 'line10kvName', 
					title : '所属10kv线路名称',
					sortable: true
				},
				{
					field : 'natureQuality', 
					title : '资产性质',
					sortable: true,
                    visible: false
				},
				{
					field : 'gisCode', 
					title : 'gis编码',
					sortable: true,
                    visible: false
				},
				{
					field : 'lgt', 
					title : '经度',
					sortable: true,
                    visible: false
				},
				{
					field : 'lat', 
					title : '纬度',
					sortable: true,
                    visible: false
				},
				{
					field : 'alt', 
					title : '高程',
					sortable: true,
                    visible: false
				},
				{
					field : 'addUser', 
					title : '创建人',
					sortable: true,
                    visible: false
				},
				{
					field : 'addDate', 
					title : '创建日期',
					sortable: true,
                    formatter: function (value, row, index) {
                        return value!=null?new Date(value).Format('yyyy-MM-dd'):"";
                    },
                    visible: false
				},
				{
					field : 'updateUser', 
					title : '最近更新人',
					sortable: true,
                    visible: false

				},
				{
					field : 'updateDate', 
					title : '最近更新日期',
					sortable: true,
                    formatter: function (value, row, index) {
                        return value!=null?new Date(value).Format('yyyy-MM-dd'):"";
                    },
                    visible: false
				},
				{
					field : 'datastate', 
					title : '数据状态',
					sortable: true,
                    visible: false
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
//                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="showAssetsInfo(\'' + row.id+'\',\'' + row.name + '\')"><i class="fa fa-edit"></i>资产概览</a>');
//                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="exportAssets(\'' + row.id+'\',\'' + row.name + '\')"><i class="fa fa-edit"></i>导出资产</a>');
                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="Assets(\'' + row.id+'\')"><i class="fa fa-edit"></i>资产预览</a>');
//                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="exportLineAssets(\'' + row.id + '\',\'' + row.name + '\')"><i class="fa fa-edit"></i>导出台账</a>');
                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="LineAssets(\'' + row.id + '\')"><i class="fa fa-edit"></i>台账预览</a>');
//                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="exportPhoto(\'' + row.id + '\')"><i class="fa fa-edit"></i>导出照片</a>');
                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="photoInfo(\'' + row.id + '\')"><i class="fa fa-edit"></i>台区照片</a>');
                        actions.push('<a class="btn btn-success btn-xs " href="#" onclick="exportCad(\'' + row.id + '\')"><i class="fa fa-edit"></i>单线图</a>');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join(' ');
		            }
		        }]
            };
            $.table.init(options);
        });


        /**
		 * 	日期格式化
         */
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }


        /**
		 * 	资产概览
		 */
//        function showAssetsInfo() {
//            alert("资产概览")
//            var url = ctx+"assets/bByq/showAssets/" + byq_id;
//            createMenuItem(url, "单线图");
//        }


        /**
         * 	导出资产
         */
        /*function exportAssets(id,name) {
            var url = ctx+ "assets/exportDetiail/Assets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-资产表";
                    window.location.href = ctx + "assets/exportDetiail/common/download?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });

        }*/

        function exportAssets(id,name) {
            var url = ctx+ "assets/exportDetiail_Excel/Assets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-资产表";
                    window.location.href = ctx + "assets/exportDetiail_Excel/expAssets?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });
        }


        /**
         * 	导出台账
         */
        /*function exportLineAssets(id,name) {
            var url = ctx+ "assets/exportDetiail/LineAssets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-台账表";
                    window.location.href = ctx + "assets/exportDetiail/common/download?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });

        }*/
        function exportLineAssets(id,name) {
            var url = ctx+ "assets/exportDetiail_Excel/LineAssets";
            $.ajax({
                type : "POST",
                url : url,
                data : {
                    "id":id
                },
                error : function(request) {
                    $.modal.alertError("导出数据错误，请联系管理员！");
                },
                success : function(data) {
                    var fileName = name+"-台账表";
                    window.location.href = ctx + "assets/exportDetiail_Excel/expLineAssets?fileName=" + fileName+ "&id=" + id+ "&delete=" + true;
                }
            });

        }



        /**
		 * 	资产详情
		 */
        function Assets(id) {
            var url = ctx+ "assets/ThyDetiail/showThp/"+id;
            createMenuItem(url,"资产预览");
        }

        /**
		 * 	台账详情
		 */
        function LineAssets(id) {
            var url = ctx+ "assets/ThyDetiail/showThy/"+id;
            createMenuItem(url,"台账预览");
        }


        /**
         * 	导出照片
         */
        function exportPhoto(id) {
            var url = ctx+ "assets/exportDetiail_Excel/photo?id="+id;
            window.location.href = url;
        }

        /**
		 *	点位照片
		 */
        function photoInfo(id) {
            var url = ctx+"assets/iPicture/iPictureShow/" + id;
            createMenuItem(url, "台区照片");
        }


        /**
		 * 	导出变压器统计
		 */
		function exportByq() {
            window.location.href = ctx + "assets/exportDetiail_Excel/expByqMB";
        }

        /**
		 * 	导出全所资产
		 */
		function exportAllAssets() {
            window.location.href = ctx + "assets/exportDetiail_Test/exportAllAssets";
        }

        /**
		 * 	单线图展示
         * @param id
         */
        function exportCad(byq_id) {
            var url = ctx+"assets/bByq/showDxf/" + byq_id;
            createMenuItem(url, "单线图");
        }


	</script>
</body>
</html>